<?php

namespace App\Admin\Controllers;

use App\Models\ChinaAreaModel;
use Dcat\Admin\Controllers\AdminController;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;

class ChinaAreaController extends AdminController
{

    public function getProvince(){
        return ChinaAreaModel::where(['parent_id' => 1])->get(['id', DB::raw('name as text')]);
    }

    public function getDCity(Request $request){
        $id = $request->get('q');
        return ChinaAreaModel::where(['parent_id' => $id])->get(['id', DB::raw('name as text')]);
    }

    public function getArea(Request $request){
        $id = $request->get('q');
        return ChinaAreaModel::where(['parent_id' => $id])->get(['id', DB::raw('name as text')]);
    }


}
